//
//  GSRenderedObject.h
//  GSEngine
//
//  Created by Александр on 02.02.14.
//  Copyright (c) 2014 SNK. All rights reserved.
//

#ifndef __GSEngine__GSRenderedObject__
#define __GSEngine__GSRenderedObject__

#include <iostream>
#include "GSEntity.h"
#include <GSEngine/Math/Vector3.h>
#include <GSEngine/Math/Matrix4.h>
#include <GSEngine/Render/ShaderProgram.h>
#include <GSEngine/Resource/GSTexture.h>

namespace GSEngine
{
    enum EEntityType
    {
        ESpriteEntity = 0,
        EModelEntity  = 1
    };
    class GSRenderedObject : public GSEntity
    {
    private:
        //data
        vec3f m_position;
        vec3f m_scale;
        vec3f m_rotation;
        vec3f m_hotSpot;
        float m_opacity;
        bool  m_isVisible;
        mat4  m_worldMatrix;
        ShaderProgram* m_shaderProgram;
        float* m_vertexCoords;
        unsigned short* m_indices;
        float* m_texCoords;
        float* m_normCoords;
        int m_vertexCount;
        int m_indicesCount;
        unsigned int m_texture;
        EEntityType m_type;
    public:
        //methods
        GSRenderedObject();
        ~GSRenderedObject();
        //render самого себя
        void render();
        //object methods
        // set position vec3 (x, y, z)
        void setPosition(vec3f pos);
        // set scale vec3 (scaleX, scaleY, scaleZ)
        void setScale(vec3f scale);
        // set rotation vec3 (rotX, rotY, rotZ)
        void setRotation(vec3f rot);
        // set hotSpot vec3(x,y,z)
        void setHotSpot(vec3f hotSpot);
        // set opacity object 0..1 float
        void setOpacity(float opacity);
        // set object visible true - false
        void setVisible(bool isVisible);
        // calculating world matrix
        void updateWorldMatrix();
        
        // get position vec3 (x, y, z)
        vec3f getPosition();
        // get scale vec3 (scaleX, scaleY, scaleZ)
        vec3f getScale();
        // get rotation vec3 (rotX, rotY, rotZ)
        vec3f getRotation();
        // set hotSpot vec3(x,y,z)
        vec3f getHotSpot();
        // set opacity object 0..1 float
        float getOpacity();
        // get object visibility
        bool isVisible();
        // get worldMatrix
        mat4 getWorldMatrix();
        // get shader program
        unsigned int getShaderProgram();
        // vertexes
        // set
        void setVertexCoords(float* vertexCoords, int count);
        void setIndices(unsigned short* indices, int arrSize);
        void setTextureCoords(float* texCoords, int count);
        void setNormalsCoords(float* normCoords, int arrSize);
        void setVertexCount(int vertexCount);
        void setIndicesCount(int indicesCount);
        // get
        float* getVertexCoords();
        unsigned short* getIndices();
        float* getTextureCoords();
        float* getNormCoords();
        int getVertexCount();
        int getIndicesCount();
        // texture
        // set texture
        void setTexture(GSTexture* texture);
        // get texture
        unsigned int getTexture();
        // set shader source
        void setShader(EShaderType type, const char* path);
        // set entity type
        void setType(EEntityType type);
        // get entity type
        EEntityType getType();
    };
}


#endif /* defined(__GSEngine__GSRenderedObject__) */
